﻿/*  Copyright 2012 PerceiveIT Limited
 *  This file is part of the Scryber library.
 *
 *  You can redistribute Scryber and/or modify 
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  Scryber is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Scryber source code in the COPYING.txt file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Scryber.Drawing;

namespace Scryber.Styles.Old
{
    [PDFParsableComponent("List")]
    public class PDFListStyle : PDFStyleItem
    {

        public PDFListStyle()
            : this(PDFObjectTypes.StyleList, NOT_INHERITED)
        {
        }

        protected PDFListStyle(PDFObjectType type, bool inherited)
            : base(type, inherited)
        { }

        #region public ListNumberingGroupStyle NumberingStyle {get;set;}

        /// <summary>
        /// Gets or sets the numbering type of this list style
        /// </summary>
        [PDFAttribute(StyleKeys.ListNumberStyleAttr)]
        public ListNumberingGroupStyle NumberingStyle
        {
            get
            {
                object value;
                if (this.GetEnumValue(StyleKeys.ListNumberStyleAttr, typeof(ListNumberingGroupStyle), false, out value))
                    return (ListNumberingGroupStyle)value;
                else
                    return ListNumberingGroupStyle.None;
            }
            set
            {
                this.SetValue(StyleKeys.ListNumberStyleAttr, value);
            }
        }

        #endregion

        #region public string NumberingGroup {get;set;}

        /// <summary>
        /// Gets or sets the numbering group for this style
        /// </summary>
        [PDFAttribute(StyleKeys.ListNumberGroupAttr)]
        public string NumberingGroup
        {
            get
            {
                string value;
                if (this.GetStringValue(StyleKeys.ListNumberGroupAttr, false, out value))
                    return value;
                else
                    return string.Empty;
            }
            set
            {
                this.SetValue(StyleKeys.ListNumberGroupAttr, value);
            }
        }

        #endregion

        #region public PDFUnit NumberInset {get;set;}

        /// <summary>
        /// Gets or sets the inset of the number from the start of the line
        /// </summary>
        [PDFAttribute(StyleKeys.ListNumberInset)]
        public PDFUnit NumberInset
        {
            get
            {
                PDFUnit value;
                if (this.GetUnitValue(StyleKeys.ListNumberInset, false, out value))
                    return value;
                else
                    return PDFStyleConst.DefaultListNumberInset;
            }
            set
            {
                this.SetValue(StyleKeys.ListNumberInset, value);
            }
        }

        #endregion

        #region public string NumberPrefix {get;set;}

        /// <summary>
        /// Gets or sets the prefix string that will be before the number in the list item
        /// </summary>
        [PDFAttribute(StyleKeys.ListPrefixAttr)]
        public string NumberPrefix
        {
            get
            {
                string value;
                if (this.GetStringValue(StyleKeys.ListPrefixAttr, false, out value))
                    return value;
                else
                    return string.Empty;
            }
            set
            {
                this.SetValue(StyleKeys.ListPrefixAttr, value);
            }
        }

        #endregion

        #region public string NumberPostfix {get;set;}

        /// <summary>
        /// Gets or sets the postfix string that will be after the number in the list item
        /// </summary>
        [PDFAttribute(StyleKeys.ListPostfixAttr)]
        public string NumberPostfix
        {
            get
            {
                string value;
                if (this.GetStringValue(StyleKeys.ListPostfixAttr, false, out value))
                    return value;
                else
                    return string.Empty;
            }
            set
            {
                this.SetValue(StyleKeys.ListPostfixAttr, value);
            }
        }

        #endregion

        #region public HorizontalAlignment NumberAlignment {get;set;}

        /// <summary>
        /// Gets or sets the alignement of the item number (or label / image) that is shown
        /// </summary>
        [PDFAttribute(StyleKeys.ListNumberAlignment)]
        public HorizontalAlignment NumberAlignment
        {
            get
            {
                object value;
                if (this.GetEnumValue(StyleKeys.ListNumberAlignment, typeof(HorizontalAlignment), false, out value))
                    return (HorizontalAlignment)value;
                else
                    return PDFStyleConst.DefaultListNumberAlignment;
            }
            set
            {
                this.SetValue(StyleKeys.ListNumberAlignment, value);
            }
        }

        #endregion

        #region public bool ConcatenateWithParent {get;set;}

        /// <summary>
        /// Gets or sets the flag to indicate if this list style should be concatenated with any parent list number schemes (lists that contain lists) during layout.
        /// </summary>
        [PDFAttribute(StyleKeys.ListConcatenateAttr)]
        public bool ConcatenateWithParent
        {
            get
            {
                bool value;
                if (this.GetBoolValue(StyleKeys.ListConcatenateAttr, false, out value))
                    return value;
                else
                    return false;
            }
            set
            {
                this.SetValue(StyleKeys.ListConcatenateAttr, value);
            }
        }

        #endregion

        #region public string ItemLabel {get;set;}

        /// <summary>
        /// Gets or sets the label associated with the current list item.
        /// Only used if the number style is label
        /// </summary>
        [PDFAttribute(StyleKeys.ListItemLabelAttr)]
        public string ItemLabel
        {
            get
            {
                string value;
                if (this.GetStringValue(StyleKeys.ListItemLabelAttr, false, out value))
                    return value;
                else
                    return string.Empty;
            }
            set
            {
                this.SetValue(StyleKeys.ListItemLabelAttr, value);
            }
        }

        #endregion
    }
}
